package com.globalwave.datasync.sqlgen;

import com.globalwave.datasync.SyncColumn;
import com.globalwave.datasync.SyncConfig;
import com.globalwave.datasync.SyncTable;

public class MoveModeSqlGenerator extends BaseBatchSqlGenerator {

	public MoveModeSqlGenerator(SyncConfig config) {
		super(config);
	}
	
	
	public void buildSourceDeleteSQL(){
		StringBuffer sqlBuffer = new StringBuffer() ;
        
		SyncTable table = config.getSource() ; 
		SyncColumn[] keys = table.getKeys() ;
		
		sqlBuffer.append(" delete from ").append(table.getTableName())
				 .append(" where ").append(keys[0].getSyncColumnsCode())
				 .append(">=? and ").append(keys[0].getSyncColumnsCode()).append("<=? " )
				 .append(getFilter(table));
            
        config.setSourceDeleteSQL(sqlBuffer.toString());
	}
	
}
